<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('修改题目')" />
</head>
<body class="gray-bg">
	
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-title">
						<h5>修改题目</h5>
					</div>
					<div class="ibox-content">
						<form class="form-horizontal m" id="form-question-edit" th:object="${question}">
							<input name="id" th:field="*{id}" type="hidden">
							<div class="form-group">
								<label class="col-sm-3 control-label">题目内容：</label>
								<div class="col-sm-8">
									<textarea name="questionTitle" th:field="*{questionTitle}" class="form-control" rows="3" required></textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">题目类型：</label>
								<div class="col-sm-8">
									<select name="questionType" th:field="*{questionType}" class="form-control">
										<option value="1">单选</option>
										<option value="2">多选</option>
										<option value="3">判断</option>
										<option value="4">填空</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">所属分类：</label>
								<div class="col-sm-8">
									<select name="categoryId" class="form-control">
										<option value="">请选择分类</option>
										<option th:each="category : ${categories}" th:value="${category.id}" th:text="${category.categoryName}" th:selected="${category.id == question.categoryId}"></option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">难度：</label>
								<div class="col-sm-8">
									<select name="difficulty" th:field="*{difficulty}" class="form-control">
										<option value="1">简单</option>
										<option value="2">中等</option>
										<option value="3">困难</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">选项A：</label>
								<div class="col-sm-8">
									<input name="optionA" th:field="*{optionA}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">选项B：</label>
								<div class="col-sm-8">
									<input name="optionB" th:field="*{optionB}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">选项C：</label>
								<div class="col-sm-8">
									<input name="optionC" th:field="*{optionC}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">选项D：</label>
								<div class="col-sm-8">
									<input name="optionD" th:field="*{optionD}" class="form-control" type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">正确答案：</label>
								<div class="col-sm-8">
									<input name="correctAnswer" th:field="*{correctAnswer}" class="form-control" type="text" required>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">答案解析：</label>
								<div class="col-sm-8">
									<textarea name="analysis" th:field="*{analysis}" class="form-control" rows="3"></textarea>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">状态：</label>
								<div class="col-sm-8">
									<select name="status" th:field="*{status}" class="form-control">
										<option value="1">启用</option>
										<option value="0">禁用</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">删除标志：</label>
								<div class="col-sm-8">
									<select name="delFlag" th:field="*{delFlag}" class="form-control">
										<option value="0">正常</option>
										<option value="1">删除</option>
									</select>
								</div>
							</div>
							<div class="form-group">
								<div class="form-control-static col-sm-offset-9">
									<button type="submit" class="btn btn-primary">提交</button>
									<button type="button" class="btn btn-danger" onclick="closeItem()">关闭</button>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<th:block th:include="include :: footer" />
	
	<script type="text/javascript">
		var prefix = ctx + "system/question/question";
		
		$("#form-question-edit").validate({
			rules: {
				questionTitle: {
					required: true
				},
				correctAnswer: {
					required: true
				}
			},
			messages: {
				questionTitle: {
					required: "请输入题目内容"
				},
				correctAnswer: {
					required: "请输入正确答案"
				}
			},
			submitHandler: function(form) {
				$.operate.save(prefix + "/edit", $('#form-question-edit').serialize());
			}
		});
		
		function closeItem() {
			var index = parent.layer.getFrameIndex(window.name);
			parent.layer.close(index);
		}
	</script>
</body>
</html>